#include "bp_intf.h"
#include "bpcontrolhandle.h"

using namespace rtdev;

#define CHECKHADNLE(s)       \
    do {                     \
        s = get_bp_handle(); \
        if (s == nullptr)    \
        {                    \
            return;          \
        }                    \
    } while (0)

void set_bp_logo_color(uint8_t color)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_logo_color((ControlHandleColor)color);
}

void set_bP_logo_brightness(uint8_t data)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_lock_brightness(data);
}

void set_bp_lock_color(uint8_t color)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_lock_color((ControlHandleColor)color);
}

void set_bp_lock_brightness(uint8_t data)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_lock_brightness(data);
}

void set_bp_beep(uint8_t data)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_beep(data);
}

void set_bp_in_init_pos(bool done)
{
    BPControlHandle* s;
    CHECKHADNLE(s);
    s->set_bp_in_init_pos(done);
}

void get_bp_button_event_status(BPHandleButton* status)
{
    memset(status, 0, sizeof(BPHandleButton));
    BPControlHandle* s;
    CHECKHADNLE(s);
    *status = s->handle_button_event_status();
}
